'use strict';

import React from 'react';
import conf from '../../config';
import {Card,Col,Row} from 'antd';
import './index.less';

class Projects extends React.Component{
  constructor(props){
    super(props);
    this.state = {
      projectlist:[],
      statistics:''
    }
    this.getProjectList();
  }

  componentDidMount(){
    this.getProjectList();
  }

  getProjectList(){
    var p_info = [];
    var _statistics= Array();
    fetch(conf.baseUrl+`/project/List`)
    .then(response => response.json())
    .then(responseData => {
        console.log(responseData.data);
        var data = responseData.data
        _statistics['sum'] = data.length;
        console.log(_statistics);
        console.log(this.state.statistics);

        this.setState({
          statistics:_statistics,
          projectlist:responseData.data,
        })
        console.log(this.state.projectlist);
    })
    .catch(function(ex){
      console.log('failed',ex);
    })
  }

  render(){
    var p_list = this.state.projectlist;
    // console.log('11sdfasd',p_list);
    //
    // // var p_list = [];
    var i= 0
    const list = p_list.map(function(item){
      i +=1;
      return(
          <Col span='8' key={i}>
            <Card title={item.title} bordered={'false'}>
            {item.description}
            <div className="p-data">
              Date {item.start_time}--{item.end_time}
            </div>
            </Card>
          </Col>
      )
    })
    return(
      <div>
        <div className='p-title'>项目</div>
        <div style={{paddingTop:'10px'}}>
          <Row className="p-list">
            {list}
          </Row>

        </div>
      </div>
    )
  }
}

export {Projects as default};
